package com.lxh.lxhcrm.model.pojos;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.util.Date;
import java.util.Objects;

@Entity
@Table(name = "emp", schema = "lxh_crm", catalog = "")
public class Emp {
    private int empId;
    private Integer bossId;
    private String empName;
    private Integer empSex;
    private String empTel;
    private String password;
    private String defaultPicture;/*默认图片*/
    @Override
    public String toString() {
        return "Emp{" +
                "empId=" + empId +
                ", bossId=" + bossId +
                ", empName='" + empName + '\'' +
                ", empSex=" + empSex +
                ", empTel='" + empTel + '\'' +
                ", password='" + password + '\'' +
                ", directBoss=" + directBoss +
                ", sysRoleId=" + sysRoleId +
                ", isOnJob=" + isOnJob +
                ", portraitSrc='" + portraitSrc + '\'' +
                ", hireDate=" + hireDate +
                ", empSalary=" + empSalary +
                ", dept=" + dept +
                ", pos=" + pos +
                '}';
    }

    private Integer directBoss;
    private Integer sysRoleId;
    private Integer isOnJob;
    private String portraitSrc;
    private Date hireDate;
    private Integer empSalary;
    /*员工对部门多对一*/
    private Department dept;
    /*员工对职位多对一*/
    private Position pos;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="department_id")
    public Department getDept() {
        return dept;
    }

    public void setDept(Department dept) {
        this.dept = dept;
    }
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="position_id")
    public Position getPos() {
        return pos;
    }

    public void setPos(Position pos) {
        this.pos = pos;
    }

    @Basic
    @Column(name = "hire_date", nullable = true)
    public Date getHireDate() {
        return hireDate;
    }

    public void setHireDate(Date hireDate) {
        this.hireDate = hireDate;
    }

    public String getDefaultPicture() {
        return defaultPicture;
    }

    public void setDefaultPicture(String defaultPicture) {
        this.defaultPicture = defaultPicture;
    }

    @Id
    @Column(name = "emp_id", nullable = false)
    public int getEmpId() {
        return empId;
    }

    public void setEmpId(int empId) {
        this.empId = empId;
    }

    @Basic
    @Column(name = "boss_id", nullable = true)
    public Integer getBossId() {
        return bossId;
    }

    public void setBossId(Integer bossId) {
        this.bossId = bossId;
    }

    @Basic
    @Column(name = "emp_name", nullable = true, length = 20)
    public String getEmpName() {
        return empName;
    }

    public void setEmpName(String empName) {
        this.empName = empName;
    }

    @Basic
    @Column(name = "emp_sex", nullable = true)
    public Integer getEmpSex() {
        return empSex;
    }

    public void setEmpSex(Integer empSex) {
        this.empSex = empSex;
    }

    @Basic
    @Column(name = "emp_tel", nullable = true, length = 10)
    public String getEmpTel() {
        return empTel;
    }

    public void setEmpTel(String empTel) {
        this.empTel = empTel;
    }

    @Basic
    @Column(name = "password", nullable = true, length = 20)
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Basic
    @Column(name = "direct_boss", nullable = true)
    public Integer getDirectBoss() {
        return directBoss;
    }

    public void setDirectBoss(Integer directBoss) {
        this.directBoss = directBoss;
    }

    @Basic
    @Column(name = "sys_role_id", nullable = true)
    public Integer getSysRoleId() {
        return sysRoleId;
    }

    public void setSysRoleId(Integer sysRoleId) {
        this.sysRoleId = sysRoleId;
    }

    @Basic
    @Column(name = "is_on_job", nullable = true)
    public Integer getIsOnJob() {
        return isOnJob;
    }

    public void setIsOnJob(Integer isOnJob) {
        this.isOnJob = isOnJob;
    }

    @Basic
    @Column(name = "portrait_src", nullable = true, length = 255)
    public String getPortraitSrc() {
        return portraitSrc;
    }

    public void setPortraitSrc(String portraitSrc) {
        this.portraitSrc = portraitSrc;
    }

    @Basic
    @Column(name = "emp_salary", nullable = true)
    public Integer getEmpSalary() {
        return empSalary;
    }

    public void setEmpSalary(Integer empSalary) {
        this.empSalary = empSalary;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Emp empEntity = (Emp) o;
        return empId == empEntity.empId &&
                Objects.equals(bossId, empEntity.bossId) &&
                Objects.equals(empName, empEntity.empName) &&
                Objects.equals(empSex, empEntity.empSex) &&
                Objects.equals(empTel, empEntity.empTel) &&
                Objects.equals(password, empEntity.password) &&
                Objects.equals(directBoss, empEntity.directBoss) &&
                Objects.equals(sysRoleId, empEntity.sysRoleId) &&
                Objects.equals(isOnJob, empEntity.isOnJob) &&
                Objects.equals(portraitSrc, empEntity.portraitSrc) &&
                Objects.equals(empSalary, empEntity.empSalary);
    }

    @Override
    public int hashCode() {
        return Objects.hash(empId, bossId, empName, empSex, empTel, password, directBoss, sysRoleId, isOnJob, portraitSrc, empSalary);
    }
}
